/* GUI CONVERTED from rcscmtb1.p (converter v1.75) Sat Aug 12 23:01:27 2000 */
/* rcscmtb1.p - Release Management Customer Schedules                         */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/*V8:ConvertMode=Maintenance                                                  */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                       */
/* REVISION: 8.6    LAST MODIFIED: 09/20/96          BY: TSI *K005*           */
/* REVISION: 8.6    LAST MODIFIED: 12/02/96          BY: *K02Q* Chris Theisen */
/* REVISION: 8.6E   LAST MODIFIED: 04/10/98          BY: *K1ND* A. Licha      */
/* REVISION: 8.6E   LAST MODIFIED: 05/20/98          BY: *K1Q4* Alfred Tan    */
/* REVISION: 8.6E   LAST MODIFIED: 10/04/98          BY: *J314* Alfred Tan    */
/* REVISION: 8.6E   LAST MODIFIED: 08/19/99          BY: *K229* Surekha Joshi */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00 BY: *N0KP* myb                  */

         /* SCHEDULE DETAIL MAINT SUBPROGRAM */

         {mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

         /* INPUT PARAMETERS */
         define input parameter sch_recid as recid no-undo.

         /* LOCAL VARIABLES */
         define variable i as integer no-undo.
         define variable pschddet_recid as recid no-undo.
         define variable schddet_recid as recid no-undo.
         define variable cmmts as logical no-undo.
         define variable rqmts as logical no-undo.
         define variable rqmmt_error as logical no-undo.
         define variable new_schd_det as logical no-undo.

         /* NEW SHARED VARIABLES */
         define new shared variable cmtindx as integer.

         {rcscfrm.i}

         find sch_mstr
            where recid(sch_mstr) = sch_recid
            no-lock.

         find so_mstr
            where so_nbr = sch_nbr
            no-lock.

/*K229*/ /* DO NOT DISPLAY/PRINT COMPLETELY SHIPPED SCHD_DET RECORDS */
         find first schd_det
            where schd_type                         = sch_type
              and schd_nbr                          = sch_nbr
              and schd_line                         = sch_line
              and schd_rlse_id                      = sch_rlse_id
/*K229*/      and trim(substring(schd_fc_qual,2,1)) = ""
            no-lock no-error.

         schddet_recid = if available schd_det
                            then recid(schd_det) else ?.

         detail-loop:
         repeat with frame sched_det:
/*GUI*/ if global-beam-me-up then undo, leave.


            ststatus = stline[1].
            status input ststatus.

            if rqmmt_error then
            do:
               /* REPAINT DOWN FRAME */
/*K1ND*/       /* ADDED INPUT PARAMETER NEW_SCHD_DET */
               {gprun.i ""rcscmtb3.p"" "(input schddet_recid,
                                         input new_schd_det)" }
/*GUI*/ if global-beam-me-up then undo, leave.


               find schd_det
                  where recid(schd_det) = schddet_recid
                  exclusive-lock.

               rqmmt_error = false.

            end. /* if rqmmt_error */

            else
            if available schd_det then
            do:
               /* CHECK FOR REQUIREMENT DETAIL */
               {gprun.i ""rcrqmyn.p"" "(input recid(schd_det),
                                        input-output rqmts)"}
/*GUI*/ if global-beam-me-up then undo, leave.

               display
                  schd_date
                  schd_time
                  schd_interval
                  schd_reference
                  schd_upd_qty
                  schd_fc_qual
                  if schd_cmtindx > 0 then yes else no @ cmmts
                  rqmts.

               /* PUT USER IN SAME FIELD WHEN CURSOR UP/DOWN */
               if frame-field = "schd_date" then
                  next-prompt schd_date.
               else
               if frame-field = "schd_time" then
                  next-prompt schd_time.
               else
               if frame-field = "schd_interval" then
                  next-prompt schd_interval.
               else
               if frame-field = "schd_reference" then
                  next-prompt schd_reference.

            end.

            prompt-for
               schd_date
               schd_time
/*K02Q*        schd_interval */
/*K02Q*/       schd_interval when (sch_type <> 3)
               schd_reference
               go-on(F9 F10 CURSOR-UP CURSOR-DOWN).
            pause 0.

            /********************************************************/
            /* CURSOR-UP                                            */
            /********************************************************/
            if lastkey = keycode("F9")
               or lastkey = keycode("CURSOR-UP") then
            do:

/*K229*/       /* DO NOT DISPLAY/PRINT COMPLETELY SHIPPED SCHD_DET RECORDS */
               find prev schd_det
                  where schd_type                         = sch_type
                    and schd_nbr                          = sch_nbr
                    and schd_line                         = sch_line
                    and schd_rlse_id                      = sch_rlse_id
/*K229*/            and trim(substring(schd_fc_qual,2,1)) = ""
                  exclusive-lock no-error.

               if available schd_det then
                  up 1.
               else
               do:
                  {mfmsg.i 21 1}

/*K229*/          /* DO NOT DISPLAY/PRINT COMPLETELY SHIPPED SCHD_DET RECORDS */
                  find first schd_det
                     where schd_type                         = sch_type
                       and schd_nbr                          = sch_nbr
                       and schd_line                         = sch_line
                       and schd_rlse_id                      = sch_rlse_id
/*K229*/               and trim(substring(schd_fc_qual,2,1)) = ""
                     exclusive-lock no-error.
               end.
            end. /* CURSOR-UP */

            /********************************************************/
            /* CURSOR-DOWN                                          */
            /********************************************************/
            else
            if lastkey = keycode("F10")
               or lastkey = keycode("CURSOR-DOWN") then
            do:

/*K229*/       /* DO NOT DISPLAY/PRINT COMPLETELY SHIPPED SCHD_DET RECORDS */
               find next schd_det
                  where schd_type                         = sch_type
                    and schd_nbr                          = sch_nbr
                    and schd_line                         = sch_line
                    and schd_rlse_id                      = sch_rlse_id
/*K229*/            and trim(substring(schd_fc_qual,2,1)) = ""
                  exclusive-lock no-error.

               if available schd_det then
                  down 1.
               else
               do:
                  {mfmsg.i 20 1}

/*K229*/          /* DO NOT DISPLAY/PRINT COMPLETELY SHIPPED SCHD_DET RECORDS */
                  find last schd_det
                     where schd_type                         = sch_type
                       and schd_nbr                          = sch_nbr
                       and schd_line                         = sch_line
                       and schd_rlse_id                      = sch_rlse_id
/*K229*/               and trim(substring(schd_fc_qual,2,1)) = ""
                     exclusive-lock no-error.
               end.
            end. /* CURSOR-DOWN */

            /********************************************************/
            /* NEW/MODIFIED RECORD                                  */
            /********************************************************/
            else
            do:
               pschddet_recid = if available schd_det
                                   then recid(schd_det) else ?.

/*K229*/       /* DO NOT DISPLAY/PRINT COMPLETELY SHIPPED SCHD_DET RECORDS */
               find schd_det
                  where schd_type                         = sch_type
                    and schd_nbr                          = sch_nbr
                    and schd_line                         = sch_line
                    and schd_rlse_id                      = sch_rlse_id
                    and schd_date                         = input schd_date
                    and schd_time                         = input schd_time
                    and schd_interval                     = input schd_interval
                    and schd_reference                    = input schd_reference
/*K229*/            and trim(substring(schd_fc_qual,2,1)) = ""
                  exclusive-lock no-error.

               if not available schd_det then
               do:

                  create schd_det.
                  assign
                     schd_type       = sch_type
                     schd_nbr        = sch_nbr
                     schd_line       = sch_line
                     schd_rlse_id    = sch_rlse_id
                     schd_date
                     schd_time
                     schd_interval
/*K02Q*/             schd_interval   = if sch_type = 3
/*K02Q*/                  then "D" else schd_interval
                     schd_reference
/*K229**             schd_fc_qual    = "F" */
/*K229*/             substring(schd_fc_qual,1,1) = "F"
                     new_schd_det    = yes
                  .

               end.
               else
                  new_schd_det = no.

               /* VALIDATE INTERVAL CODE */
               if not ({gpcode.v schd_interval}) then
               do:
                  {mfmsg.i 716 3}

                  next-prompt schd_interval
                     with frame sched_det.

                  undo, retry.
               end.

               schddet_recid = recid(schd_det).

               /* REPAINT DOWN FRAME */
/*K1ND*/       /* ADDED INPUT PARAMETER NEW_SCHD_DET */
               {gprun.i ""rcscmtb3.p"" "(input schddet_recid,
                                         input new_schd_det)" }
/*GUI*/ if global-beam-me-up then undo, leave.


               pause 0.

               find schd_det
                  where recid(schd_det) = schddet_recid
                  exclusive-lock.

               ststatus = stline[2].
               status input ststatus.

               /* MAINTAIN REQUIREMENT DETAIL */
               if new_schd_det
                  and schd_reference ne ""
                  and schd_type = 3 then
               do:
                  {gprun.i ""rcrqmmt.p"" "(input recid(schd_det),
                                           input-output schd_reference)"}
/*GUI*/ if global-beam-me-up then undo, leave.


                  if schd_reference = "" then
                  do:
                     find schd_det
                        where recid(schd_det) = pschddet_recid
                        exclusive-lock.

                     assign
                        rqmmt_error = true.
                        schddet_recid = pschddet_recid.

                     undo, retry detail-loop.
                  end.
               end.
               else
               if new_schd_det then
               do:
                  {mfmsg.i 1 1}
               end.

               /* MAINTAIN RIGHT SIDE OF DETAIL DATA FRAME */
               {gprun.i ""rcscmtb2.p"" "(input-output schddet_recid)"}
/*GUI*/ if global-beam-me-up then undo, leave.


               find schd_det
                  where recid(schd_det) = schddet_recid
                  no-lock no-error.

            end. /* NEW/MODIFIED RECORD */

         end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* detail-loop */
